var devTypeId = 'all'; //判断当前地图展示的设备是什么
// if(localStorage.getItem('loginName')='hbjd'){
//   devTypeId=1;
// }
var devTypeStatus = '';
$(function () {



  // 判断登录是否成功，服务是否连接
  setInterval(function () {
    var ret = userOut();
    ret.catch(function (err) {
      
      window.location.reload();
    });
  }, 30000);
  // 显示用户名
  addUserNameFunc();

  function addUserNameFunc() {
    var userName = localStorage.getItem('userName');
    userName = userName.trim();
    if (userName.length > 10) {
      $('.indexRightStyle .userName').addClass('userName1');
      $('.indexRightStyle .userText').addClass('userText1');
    }
    $(".index .userBox .userName").text(userName);

  }

  //   紫阳区域地址   创建折线
  var ziyangPolylineArr = [
    new BMap.Point(120.177628, 30.243807),
    new BMap.Point(120.185893, 30.241061),
    new BMap.Point(120.197355, 30.235195),
    new BMap.Point(120.199044, 30.234478),
    new BMap.Point(120.205583, 30.228955),
    new BMap.Point(120.187007, 30.219062),
    new BMap.Point(120.183916, 30.222745),
    new BMap.Point(120.182443, 30.223868),
    new BMap.Point(120.181832, 30.22287),
    new BMap.Point(120.181257, 30.222651),
    new BMap.Point(120.180682, 30.222277),
    new BMap.Point(120.180251, 30.222246),
    new BMap.Point(120.180647, 30.226614),
    new BMap.Point(120.180161, 30.229189),
    new BMap.Point(120.177107, 30.232106),
    new BMap.Point(120.177269, 30.23092),
    new BMap.Point(120.175095, 30.231591),
    new BMap.Point(120.173999, 30.231435),
    new BMap.Point(120.170891, 30.232855),
    new BMap.Point(120.168663, 30.233448),
    new BMap.Point(120.168834, 30.234006),
    new BMap.Point(120.169287, 30.233951),
    new BMap.Point(120.169319, 30.234981),
    new BMap.Point(120.169494, 30.235031),
    new BMap.Point(120.172387, 30.242294),
    new BMap.Point(120.173375, 30.242247),
    new BMap.Point(120.175459, 30.243432),
    new BMap.Point(120.176052, 30.243307),
    new BMap.Point(120.177628, 30.243807)
  ];
  var ziyangPolyline1 = new BMap.Polyline(ziyangPolylineArr, {
    strokeColor: "#e89f1b52",
    strokeWeight: 12,
    strokeOpacity: 0.5,
  });
  var ziyangPolyline = new BMap.Polyline(ziyangPolylineArr, {
    strokeColor: "#e89f1b",
    strokeWeight: 6,
    strokeOpacity: 0.5,
  });
  //创建多边形
  function add_ziyang_overlay() {
    map.addOverlay(ziyangPolyline1);
    map.addOverlay(ziyangPolyline); //增加多边形
  }

  function remove_ziyang_overlay() {
    map.removeOverlay(ziyangPolyline);
    map.removeOverlay(ziyangPolyline1);
  }

  //   湖滨区域地址   创建折线
  var hubinPolylineArr = [
    new BMap.Point(120.167352, 30.251863),
    new BMap.Point(120.178869, 30.251676),
    new BMap.Point(120.17824, 30.263654),
    new BMap.Point(120.170479, 30.264122),
    new BMap.Point(120.165161, 30.264029),
    new BMap.Point(120.169329, 30.257447),
    new BMap.Point(120.169293, 30.255981),
    new BMap.Point(120.168143, 30.255513),
    new BMap.Point(120.16746, 30.254577),
    new BMap.Point(120.167245, 30.253204),
    new BMap.Point(120.167388, 30.251832)
  ];
  var hubinPolyline1 = new BMap.Polyline(hubinPolylineArr, {
    // strokeColor: "RGB(65 217 255)",
    strokeWeight: 10,
    strokeOpacity: 0.5,
  });
  var hubinPolyline = new BMap.Polyline(hubinPolylineArr, {
    strokeColor: "RGB(65 217 255)",
    strokeWeight: 4,
    strokeOpacity: 0.5,
  });

  //创建多边形
  function add_hubin_overlay() {
    map.addOverlay(hubinPolyline1);
    map.addOverlay(hubinPolyline); //增加多边形
  }

  function remove_hubin_overlay() {
    map.removeOverlay(hubinPolyline);
    map.removeOverlay(hubinPolyline1);
  }
  // 湖滨街道账号登录，显示湖滨范围
  if (localStorage.getItem('loginName') == 'hbjd' || localStorage.getItem('loginName') == 'lp') {
    add_hubin_overlay();
  }

  setTimeout(function () {
    indexRightHeight();
  });

  function indexRightHeight() {
    var indexRightHeightNum = $('.indexRight .indexRightHeight').length;
    if (indexRightHeightNum == 1) {
      $('.indexRight').css('height', '25%');
      $('.indexRight .indexRightHeight').css('height', '100%');
    } else if (indexRightHeightNum == 2) {
      $('.indexRight').css('height', '50%');
      $('.indexRight .indexRightHeight').css('height', '50%');
    } else if (indexRightHeightNum == 3) {
      $('.indexRight').css('height', '75%');
      $('.indexRight .indexRightHeight').css('height', '33.3333%');
    }

    // console.log($('.devAlltoggleBtn ').outerWidth());
    // var innerWidth = $('.deviceTypeToggleBtn1').outerWidth()+159;
    // console.log($('.deviceTypeToggleBtn1').outerWidth());

    var innerWidth = $('.deviceTypeToggleBtn1').innerWidth() + 159;
    $('.indexCenterMapStyle').css('width', innerWidth);
  }
  fireStationNum();
  //	渲染用户名
  // $(".indexRight .userBox .userName").text(localStorage.getItem('userName'));

  //	关闭
  $('.sure-pop').on('click', function (event) {
    if ($(event.target).is('.cd-popup-close') || $(event.target).is('.sure-pop')) {
      event.preventDefault();
      $(this).removeClass('is-visible3');
    }
  });
  //设备编辑 打开窗口
  $('body').on('click', ".sure-trigger", function (event) {
    event.preventDefault();
    $('.sure-pop').addClass('is-visible3');
  });

  $(".configurationTableExport").tableExport({
    formats: ["xlsx"]
  });

  //	初始化日历插件
  $('.date').datepicker({
    language: "zh-CN",
    autoclose: true,
    startView: 0,
    format: "yyyy-mm-dd",
    showSecond: true, //显示秒
    timeFormat: 'HH:mm:ss', //格式化时间
    stepHour: 1, //设置步长
    stepMinute: 1,
    stepSecond: 1,
    clearBtn: false,
    todayBtn: false
  });
  //	初始化日历插件 只显示日
  $('.dateMonth').datepicker({
    language: "zh-CN",
    autoclose: true,
    // startView: 0,
    format: "yyyy-mm",
    // showSecond: true, //显示秒
    // timeFormat: 'HH:mm:ss', //格式化时间
    // stepHour: 1, //设置步长
    // stepMinute: 1,
    // stepSecond: 1,
    clearBtn: false,
    todayBtn: false
  });
  // 左上角巡更管理、日常管理、基础配置的切换
  $(".patrolManagement-title span").click(function () {

    $(this).parent().siblings().stop().slideDown("slow");
    $(this).stop().addClass('active');
    $(this).parent().parent().siblings().find('.patrolManagement-content').stop().slideUp("slow");
    $(this).parent().parent().siblings().find('.patrolManagement-title span').stop().removeClass("active");
    return false;
  });
  $('.patrolManagement-content ul li').click(function () {
    $(this).addClass('active').siblings().removeClass('active');
    //return false;
  });
  $('body').click(function () {
    $('.patrolManagement-content').stop().slideUp("slow");
    $('.patrolManagement-title span').removeClass('active');
    $('.patrolManagement-content ul li').removeClass('active')
  });
  // 右侧用户
  $('.indexRight .userText').on('click', function () {
    //        $(this).addClass('active').siblings().removeClass('active');
  });
  $(".cd-popup3").show();
  devSumFunc(devTypeId);

  //  本月报警总数
  thisMonthFunc();


  setTimeout(function () {
    alarmSumInitFunc();
  }, 1000);
  //--------数据统计---------
  $('.bigData-trigger').on('click', function (event) {
    event.preventDefault();
    map.closeInfoWindow();
    $('.bigData-pop').addClass('is-visible3');
  });
  $('.bigData-trigger1').on('click', function (event) {
    event.preventDefault();
    $('.bigData-pop1').addClass('is-visible3');
  });
  $('.bigData-pop1').on('click', function (event) {
    if ($(event.target).is('.cd-popup-close') || $(event.target).is('.bigData-pop1')) {
      event.preventDefault();
      $(this).removeClass('is-visible3');
    }
  });
  //人员管理  关闭窗口
  $('.bigData-pop').on('click', function (event) {
    if ($(event.target).is('.cd-popup-close') || $(event.target).is('.bigData-pop')) {
      event.preventDefault();
      $(this).removeClass('is-visible3');
    }
  });
  //-------------设备切换按钮--------------
  $('.pointPosition').on('click', function () {
    $(this).siblings().find('.activeToggle').removeClass('active');
    $(this).find('.activeToggle').addClass('active');
    map.closeInfoWindow();
  });
  //  点击巡更按钮
  $('#keepWatchBtn').on('click', function () {
    $(".policeRatioBox").hide();
    $(".policeRatio").hide();
    $(".rectificationMap").hide();
    $(".rectificationMapBox").hide();

    $(this).addClass('active').siblings().removeClass('active');
    devTypeId = 'keepWatch';
    devTypeStatus = '';
    $('.pointPositionBox').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').show();
    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-keep .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-keep .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    map.closeInfoWindow();
    $('.combinedActionTaskStyle').hide();
    // combinedActionMarkerHide();
    // if(localStorage.getItem('loginName')=='zyjd'||localStorage.getItem('loginName')=='lp'){
    add_ziyang_overlay();
    // }
    devSumFunc();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  $('#smokeBtn').on('click', function () {
    map.closeInfoWindow();
    devTypeId = '1';
    devTypeStatus = '';
    // $(this).addClass('active').siblings().removeClass('active');
    $(".pointPositionBox-smoke").show().siblings('.pointPositionBox').hide();
    $('.index .personnelStatisticsShow').hide();
    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-smoke .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-smoke .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    // $('.pointPositionBox-earlyWarning').hide();
    // $('.pointPositionBox-charge').hide();
    devSumFunc();
    devListSum();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  // 点击地图三色预警按钮
  $('#earlyWarningBtn').on('click', function () {
    map.closeInfoWindow();
    devTypeId = 'earlyWarning';
    devTypeStatus = '';
    $(this).addClass('active').siblings().removeClass('active');
    // $(".pointPositionBox-smoke").hide();
    $('.pointPositionBox-earlyWarning').show().siblings('.pointPositionBox').hide();
    // $('.pointPositionBox-charge').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();
    // 显示三色预警饼状图
    $(".earlyWarningChartsShow").show();
    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-earlyWarning .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-earlyWarning .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.combinedActionTaskStyle').hide();
    $('.authorizeDeviceStatistics').hide();
    $('.index .houseMasterChartsShow').hide();
    // combinedActionMarkerHide();

    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入单位名称');
  });
  $('#chargeBtn').on('click', function () {
    devTypeId = '2';
    devTypeStatus = '';
    map.closeInfoWindow();
    // $(this).addClass('active').siblings().removeClass('active');
    // $(".pointPositionBox-smoke").hide();
    // $('.pointPositionBox-earlyWarning').hide();
    $('.pointPositionBox-charge').show().siblings('.pointPositionBox').hide();
    $('.index .personnelStatisticsShow').hide();
    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-charge .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-charge .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  $('#fireplugBtn').on('click', function () {
    map.closeInfoWindow();
    devTypeId = '4';
    devTypeStatus = '';
    // $(this).addClass('active').siblings().removeClass('active');
    // $(".pointPositionBox-smoke").hide();
    // $('.pointPositionBox-earlyWarning').hide();
    $('.pointPositionBox-fireplug').show().siblings('.pointPositionBox').hide();
    $('.index .personnelStatisticsShow').hide();
    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-fireplug .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-fireplug .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  $('#waterBtn').on('click', function () {
    devTypeId = '6';
    devTypeStatus = '';
    $('.pointPositionBox-water').show().siblings('.pointPositionBox').hide();
    $('.index .personnelStatisticsShow').hide();
    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-water .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-water .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  $('#electricityBtn').on('click', function () {
    devTypeId = '5';
    devTypeStatus = '';
    $('.pointPositionBox-electricity').show().siblings('.pointPositionBox').hide();
    $('.index .personnelStatisticsShow').hide();
    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-electricity .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-electricity .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  var ziyangPolylineArr1 = [
    [120.177628, 30.243807],
    [120.185893, 30.241061],
    [120.197355, 30.235195],
    [120.199044, 30.234478],
    [120.205583, 30.228955],
    [120.187007, 30.219062],
    [120.183916, 30.222745],
    [120.182443, 30.223868],
    [120.181832, 30.22287],
    [120.181257, 30.222651],
    [120.180682, 30.222277],
    [120.180251, 30.222246],
    [120.180647, 30.226614],
    [120.180161, 30.229189],
    [120.177107, 30.232106],
    [120.177269, 30.23092],
    [120.175095, 30.231591],
    [120.173999, 30.231435],
    [120.170891, 30.232855],
    [120.168663, 30.233448],
    [120.168834, 30.234006],
    [120.169287, 30.233951],
    [120.169319, 30.234981],
    [120.169494, 30.235031],
    [120.172387, 30.242294],
    [120.173375, 30.242247],
    [120.175459, 30.243432],
    [120.176052, 30.243307],
    [120.177628, 30.24380]
  ];
  $('#GPSBtn').on('click', function () {
    devTypeId = '3';
    devTypeStatus = '';
    //('.pointPositionBox-GPS').show().siblings
    $('.pointPositionBox').hide();
    $('.index .personnelStatisticsShow').hide();
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();


    // var latitude = 120.181177;
    // var longitude = 30.227971;
    // var devCode=1;
    // var GPSAddMarkerArr = BaiDuMap.GPSAddMarker( 'status', devCode, 'deviceName', 'address', latitude, longitude, 'linkMain1', 'linkPhone1', 'linkMain2', 'linkPhone2', 'linkMain3', 'linkPhone3', 'linkMain4', 'linkPhone4');

    // // 通过控制openInfoWindowFlag的值，选择让谁显示信息窗口
    // var openInfoWindowFlag = 1;
    // setInterval(function (){
    //   GPSAddMarkerArr.removePoint();
    //   latitude+=0.0001;
    //   longitude+=0.0001;
    //   devCode+=1;
    //   var point =  new BMap.Point( latitude,longitude);
    //   GPSAddMarkerArr = BaiDuMap.GPSAddMarker( 'status', devCode, 'deviceName', 'address', latitude, longitude, 'linkMain1', 'linkPhone1', 'linkMain2', 'linkPhone2', 'linkMain3', 'linkPhone3', 'linkMain4', 'linkPhone4');
    //   var infoWindowStr = GPSAddMarkerArr.infoWindow;
    //   // GPSAddMarkerArr.removePoint;
    //   if(openInfoWindowFlag==1){
    //     map.openInfoWindow(infoWindowStr, point);
    //   }else if(openInfoWindowFlag==0){
    //     map.closeInfoWindow();
    //   }

    //   $(".BMap_pop").parent().css("top", "0px");
    //   $(".BMap_shadow").parent().css("top", "0px");
    //   $(".BMap_pop>div").eq(7).html('<div class="map-triangle"><img src="/public/images/map/map-triangle-img.png" /></div>');
    // },500);

  });

  $('#videoBtn').on('click', function () {
    devTypeId = '7';
    devTypeStatus = '';
    $('.pointPositionBox-video').show().siblings('.pointPositionBox').hide();
    $('.index .personnelStatisticsShow').hide();
    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-video .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-video .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  // //点击烟感按钮
  // $('#smokeBtn').on('click', function () {
  // 	if (devFlag) {
  // 		devFlag = false;
  // 		map.clearOverlays();
  // 		renderSomkePoint();
  // 		$(this).addClass('active').siblings().removeClass('active');
  // 		$('.indexRight .indexRightHeight1').show();
  // 		$('.indexRight .keepWatch-ziyang1').hide();
  // 		$('.indexRight .keepWatch-ziyang').hide();
  // 		$('.indexRight .keepWatch-ziyang2').hide();
  // 		$('.indexRight .keepWatch-ziyang3').hide();
  // 		$('.indexRight .keepWatch-ziyang4').hide();
  // 		$(".pointPositionBox-keep").hide();
  // 		$(".pointPositionBox-smoke").show();
  // 		$('.pointPositionBox-build').hide();
  // 	}
  // });

  //点击楼长按钮
  $('#houseMasterBtn').on('click', function () {
    map.closeInfoWindow();
    devTypeId = 'houseMaster';
    devTypeStatus = '';
    $(this).addClass('active').siblings().removeClass('active');
    $('.pointPositionBox-houseMaster').show().siblings('.pointPositionBox').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();

    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-houseMaster .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-houseMaster .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    $('.index .indexRightHeight').hide();
    $(".earlyWarningChartsShow").hide();
    $('.index .userBigBox').show();
    $('.combinedActionTaskStyle').hide();
    // combinedActionMarkerHide();
    $('.index .houseMasterChartsShow').show();
    // 隐藏
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入地址');
    devSumFunc();
  });

  //点击墙门按钮
  $('#wallDoorBtn').on('click', function () {
    map.closeInfoWindow();
    devTypeId = 'wallDoor';
    devTypeStatus = '';
    $(this).addClass('active').siblings().removeClass('active');
    $('.pointPositionBox-houseMaster').hide().siblings('.pointPositionBox').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();

    remove_ziyang_overlay();
    $('.index .indexRightHeight').hide();
    $(".earlyWarningChartsShow").hide();
    $('.index .userBigBox').show();
    $('.combinedActionTaskStyle').hide();
    // combinedActionMarkerHide();
    $('.index .houseMasterChartsShow').hide();
    // 隐藏
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入地址');
    devSumFunc();
  });
  //点击高层建筑按钮
  $('#buildingBtn').on('click', function () {
    map.closeInfoWindow();
    devTypeId = 'building';
    devTypeStatus = '';
    $(this).addClass('active').siblings().removeClass('active');
    // $('.pointPositionBox-building').show().siblings('.pointPositionBox').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();
    $('.pointPositionBox').hide();

    // 地图图标状态初始化为全部状态选中
    // $(".pointPositionBox-building .pointPosition").find('.pointPositionImg').removeClass('active');
    // $(".pointPositionBox-building .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    $('.index .indexRightHeight').hide();
    $(".earlyWarningChartsShow").hide();
    $('.index .houseMasterChartsShow').hide();
    $('.index .userBigBox').show();

    $('.combinedActionTaskStyle').hide();
    // combinedActionMarkerHide();
    // 隐藏
    // $('.index .homepageSearchBox .devAddress').attr('placeholder','请输入单位名称');
    devSumFunc();
  });
  //点击文历保按钮
  $('#wenbaoBtn').on('click', function () {
    map.closeInfoWindow();
    devTypeId = 'wenbao';
    devTypeStatus = '';
    $(this).addClass('active').siblings().removeClass('active');
    // $('.pointPositionBox-wenbao').show().siblings('.pointPositionBox').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();
    $('.pointPositionBox').hide();

    // 地图图标状态初始化为全部状态选中
    // $(".pointPositionBox-wenbao .pointPosition").find('.pointPositionImg').removeClass('active');
    // $(".pointPositionBox-wenbao .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    $('.index .indexRightHeight').hide();
    $(".earlyWarningChartsShow").hide();
    $('.index .houseMasterChartsShow').hide();
    $('.index .userBigBox').show();

    $('.combinedActionTaskStyle').hide();
    // combinedActionMarkerHide();
    // 隐藏
    // $('.index .homepageSearchBox .devAddress').attr('placeholder','请输入单位名称');
    devSumFunc();
  });
  //点击协同作战按钮
  $('.combinedActionBtn').on('click', function () {
    map.closeInfoWindow();
    devTypeId = 'combinedAction';
    devTypeStatus = '';
    $(this).addClass('active').siblings().removeClass('active');
    $('.combinedActionTaskStyle').hide().siblings('.pointPositionBox').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();

    // 地图图标状态初始化为全部状态选中
    // $(".pointPositionBox-combinedAction .pointPosition").find('.pointPositionImg').removeClass('active');
    // $(".pointPositionBox-combinedAction .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    // $('.index .indexRightHeight').hide();
    $(".earlyWarningChartsShow").hide();
    $('.index .houseMasterChartsShow').hide();
    $('.index .userBigBox').show();

    $('.deviceTypeToggleBtn1 #combinedActionBtn').addClass('active').siblings().removeClass('active');
    $('.combinedActionTaskStyle').show();
    // combinedActionMarkerHide();
    // 隐藏
    // $('.index .homepageSearchBox .devAddress').attr('placeholder','请输入单位名称');

  });
  //点击协同作战按钮,在地图显示协同点为
  $('#combinedActionBtn').on('click', function () {
    map.closeInfoWindow();
    devTypeId = 'combinedAction';
    devTypeStatus = '';
    $(this).addClass('active').siblings().removeClass('active');
    $('.combinedActionTaskStyle').hide().siblings('.pointPositionBox').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();

    // 地图图标状态初始化为全部状态选中
    // $(".pointPositionBox-combinedAction .pointPosition").find('.pointPositionImg').removeClass('active');
    // $(".pointPositionBox-combinedAction .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    // $('.index .indexRightHeight').hide();
    $(".earlyWarningChartsShow").hide();
    $('.index .houseMasterChartsShow').hide();
    $('.index .userBigBox').show();

    $('.deviceTypeToggleBtn1 #combinedActionBtn').addClass('active').siblings().removeClass('active');

    $('.pointPositionBox').hide();
    // combinedActionMarkerHide();
    // 隐藏
    // $('.index .homepageSearchBox .devAddress').attr('placeholder','请输入单位名称');
    devSumFunc();
  });
  // 岗亭
  $('#sentryBoxBtn').on('click', function () {
    devTypeId = '11';
    devTypeStatus = '';
    map.closeInfoWindow();

    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.pointPositionBox').hide();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  // 终端apk
  $('#apkBtn').on('click', function () {
    devTypeId = '10';
    devTypeStatus = '';
    map.closeInfoWindow();

    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.pointPositionBox').hide();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  // 手报
  $('#shoubaoBtn').on('click', function () {
    devTypeId = '12';
    devTypeStatus = '';
    map.closeInfoWindow();

    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.pointPositionBox').hide();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  // 重点人员
  $('#keyPersonBtn').on('click', function () {
    devTypeId = 'keyPerson';
    devTypeStatus = '';
    map.closeInfoWindow();
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.pointPositionBox').hide();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
  });
  $('.combinedActionTaskStyle span').on('click', function () {
    $('.combinedActionTaskStyle').hide();
    // combinedActionMarkerHide();
  });

  // 点击总设备按钮
  $(".devAlltoggleBtn-title span").click(function () {

    $(this).parent().siblings().stop().slideDown("slow");
    // $(this).stop().addClass('active');
    $(this).parent().parent().siblings().find('.devAlltoggleBtn-content').stop().slideUp("slow");
    $(this).parent().parent().siblings().find('.devAlltoggleBtn-title span').stop().removeClass("active");

    return false;
  });
  // 点击设备切换按钮
  $('.devAlltoggleBtn-content ul li').click(function () {
    map.closeInfoWindow();
    $(this).addClass('active').siblings().removeClass('active');
    $('.devAlltoggleBtn-title span').addClass('active');
    $('.deviceTypeToggleBtn1 li').removeClass('active');
    $('.index .personnelStatisticsShow').hide();
    $(".earlyWarningChartsShow").hide();
    $('.index .houseMasterChartsShow').hide();
    $('.combinedActionTaskStyle').hide();
    // combinedActionMarkerHide();
  });
  // 点击全部按钮 
  $('#allDevBtn').on('click', function () {
    devTypeId = 'all';
    devTypeStatus = '';
    $('.pointPositionBox').hide();
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入设备编号或地址');
    map.closeInfoWindow();
  });
  $('body').click(function () {
    $('.devAlltoggleBtn-content').stop().slideUp("slow");
    // $('.devAlltoggleBtn-title span').removeClass('active');
    $('.devAlltoggleBtn-content ul li').removeClass('active')
  });
  $(' .devAlltoggleBtn-content li').on('click', function () {
    var str = $(this).text();
    $('.devAlltoggleBtn-title span').text(str);
  });
  // 时间
  /*显示用户信息下面的时间*/
  $(".page-time").text(moment().format('YYYY-MM-DD HH:mm:ss'));
  setInterval(function () {
    $(".page-time").text(moment().format('YYYY-MM-DD HH:mm:ss'));
  }, 1000);

  // 地图模糊查询搜索
  // searchMapPointFunc(devTypeId);  
  // 判断有没有中文
  function checkChineseFunc(val) {
    var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
    if (reg.test(val)) {
      // 包含中文
      return 1;
    } else {
      // 不包含中文
      return 0;
    }
  }
  // function searchMapPointFunc(devTypeId) {
  var timeoutflag = null;
  //模糊查询
  $('body').on('click', function () {
    $(".homepageSearchList").hide();
    $(".homepageSearchListItem_scroll").hide();
  });

  function hide2border() {
    if (!($(".homepageSearchList>li").length)) {
      $(".homepageSearchList").hide();
      $(".homepageSearchListItem_scroll").hide();
    } else {
      $(".homepageSearchList").show();
      $(".homepageSearchListItem_scroll").show();
    }
  }
  var fn = _.debounce(function () {
    if (devTypeId == 'all' || devTypeId == '1' || devTypeId == '2' || devTypeId == '3' || devTypeId == '4' || devTypeId == '5' || devTypeId == '6' || devTypeId == '7' || devTypeId == '10' || devTypeId == '11' || devTypeId == '12') {
      $(".homepageSearchList").show();
      hide2border();
      if ($(".homepageSearchList li")) { //键盘抬起后就判断页面中是否存在这个元素,存在就删除
        $(".homepageSearchList li").remove();
      }
      var searchContent = $(".homepageSearchBox .devAddress").val();
      searchContent = $.trim(searchContent);

      var devTypeIdStr;
      if (devTypeId == 'all') {
        devTypeIdStr = '';
      } else {
        devTypeIdStr = '&deviceTypeId=' + devTypeId;
      }
      console.log(devTypeId)
      //查询内容存在则搜索
      // 内容包含中文显示设备地址
      if (searchContent && checkChineseFunc(searchContent) == 1) {
        $.ajax({
          url: "/device/data/list/deviceManage?searchContent=" + searchContent + devTypeIdStr,
          type: "GET",
          async: false,
          success: function (result) {
            $(".homepageSearchList").html("");
            var data = result.data.content;
            for (var i = 0; i < data.length; i++) {
              var searchAddress = data[i].device.address;
              var latitude = data[i].device.latitude;
              var longitude = data[i].device.longitude;
              var devCode = data[i].device.devCode;
              var checkChinese = checkChineseFunc(searchAddress);
              $(".homepageSearchList").append('<li devicecode="' + devCode + '" longitude="' + longitude + '" latitude="' + latitude + '">' + searchAddress + '</li>');
              hide2border();

            }
          }
        });
        // 内容不包含中文显示设备编号
      } else if (searchContent && checkChineseFunc(searchContent) == 0) {
        $.ajax({
          url: "/device/data/list/deviceManage?searchContent=" + searchContent + devTypeIdStr,
          type: "GET",
          async: false,
          success: function (result) {
            $(".homepageSearchList").html("");
            var data = result.data.content;
            for (var i = 0; i < data.length; i++) {
              var searchAddress = data[i].address;
              var latitude = data[i].device.latitude;
              var longitude = data[i].device.longitude;
              var devCode = data[i].device.devCode;
              $(".homepageSearchList").append('<li devicecode="' + devCode + '" longitude="' + longitude + '" latitude="' + latitude + '">' + devCode + '</li>');
              hide2border();

            }
          }
        });
      }
      $(".homepageSearchList").show();
      hide2border();
    } else if (devTypeId == 'earlyWarning') {
      // --------------------------------------三色预警查询
      $(".homepageSearchList").show();
      hide2border();
      if ($(".homepageSearchList li")) { //键盘抬起后就判断页面中是否存在这个元素,存在就删除
        $(".homepageSearchList li").remove();
      }
      var searchContent = $(".homepageSearchBox .devAddress").val();
      searchContent = $.trim(searchContent);
      //查询内容存在则搜索
      if (searchContent) {
        $.ajax({
          url: "/threeColor/getInfo?size=1000&page=0&unit=" + searchContent,
          type: "GET",
          async: false,
          success: function (result) {
            $(".homepageSearchList").html("");
            var data = result.data.content;
            for (var i = 0; i < data.length; i++) {
              var latitude = data[i].latitudes;
              var longitude = data[i].longitude;
              var devCode = data[i].onlyValue;
              var unit = data[i].unit;
              $(".homepageSearchList").append('<li devicecode="' + devCode + '" longitude="' + longitude + '" latitude="' + latitude + '">' + unit + '</li>');
              hide2border();

            }
          }
        });
      }
      $(".homepageSearchList").show();
      hide2border();
    } else if (devTypeId == 'houseMaster') {
      // --------------------------------------三色预警查询
      $(".homepageSearchList").show();
      hide2border();
      if ($(".homepageSearchList li")) { //键盘抬起后就判断页面中是否存在这个元素,存在就删除
        $(".homepageSearchList li").remove();
      }
      var searchContent = $(".homepageSearchBox .devAddress").val();
      searchContent = $.trim(searchContent);
      //查询内容存在则搜索
      if (searchContent) {
        $.ajax({
          url: "/building/getBuildings?size=1000&page=0&address=" + searchContent,
          type: "GET",
          async: false,
          success: function (result) {
            $(".homepageSearchList").html("");
            var data = result.data.content;
            for (var i = 0; i < data.length; i++) {
              var latitude = data[i].latitude;
              var longitude = data[i].longitude;
              var id = data[i].id;
              id = 'houseMaster' + id;
              var address = data[i].address;
              $(".homepageSearchList").append('<li devicecode="' + id + '" longitude="' + longitude + '" latitude="' + latitude + '">' + address + '</li>');
              hide2border();

            }
          }
        });
      }
      $(".homepageSearchList").show();
      hide2border();
    }
  }, 500);
  // 输入框搜索
  $(".homepageSearchBox .devAddress").on("input", function (e) {
    fn();
  });
  //直接输入地址,点击列表查询

  $(".homepageSearchList").on("click", "li", function () {
    if (devTypeId == 'houseMaster') {
      $(".homepageSearchList").show();
      var $this = $(this);
      var liVal = $this.text();
      liVal = $.trim(liVal);
      var searchVal = $(".homepageSearchBox .devAddress").val(liVal);
      var latitude = $this.attr('latitude');
      var longitude = $this.attr('longitude');
      var devicecode = $this.attr('devicecode');
      $('.homepageSearchBox i').attr('latitude', latitude);
      $('.homepageSearchBox i').attr('longitude', longitude);
      $('.homepageSearchBox i').attr('devicecode', devicecode);
      BaiDuMap.panTo(longitude, latitude);
      setTimeout(function () {
        BaiDuMap.popMenu(devicecode);
      }, 700);
      $(".homepageSearchList").html(""); //hide
    } else {
      $(".homepageSearchList").show();
      var $this = $(this);
      var liVal = $this.text();
      liVal = $.trim(liVal);
      var searchVal = $(".homepageSearchBox .devAddress").val(liVal);
      var latitude = $this.attr('latitude');
      var longitude = $this.attr('longitude');
      var devicecode = $this.attr('devicecode');
      $('.homepageSearchBox i').attr('latitude', latitude);
      $('.homepageSearchBox i').attr('longitude', longitude);
      $('.homepageSearchBox i').attr('devicecode', devicecode);
      BaiDuMap.panTo(latitude, longitude);
      setTimeout(function () {
        BaiDuMap.popMenu(devicecode);
      }, 700);
      $(".homepageSearchList").html(""); //hide
    }

    return false;
  });
  // 直接输入搜索按钮查询
  var homepageSearchListFn = _.debounce(function () {
    if (devTypeId == 'all' || devTypeId == '1' || devTypeId == '2' || devTypeId == '3' || devTypeId == '4' || devTypeId == '5' || devTypeId == '6' || devTypeId == '7') {
      var searchContent = $(".homepageSearchBox .devAddress").val();
      searchContent = $.trim(searchContent);
      var devTypeIdStr = '';
      if (devTypeId != 'all') {
        devTypeIdStr = '&deviceTypeId=' + devTypeId;
      }
      $.ajax({
        url: "/device/data/list/deviceManage?searchContent=" + searchContent + devTypeIdStr,
        type: "GET",
        async: false,
        success: function (result) {
          $(".homepageSearchList").html("");
          var data = result.data.content;
          if (data.length == 1) {
            var searchAddress = data[0].address;
            var latitude = data[0].device.latitude;
            var longitude = data[0].device.longitude;
            var devicecode = data[0].devCode;
            BaiDuMap.panTo(latitude, longitude);
            setTimeout(function () {
              BaiDuMap.popMenu(devicecode);
            }, 700);

          }

        }
      });
    } else if (devTypeId == 'earlyWarning') {
      // 搜索三色预警场所
      var searchContent = $(".homepageSearchBox .devAddress").val();
      searchContent = $.trim(searchContent);
      var devTypeIdStr = '';
      if (devTypeId != 'all') {
        devTypeIdStr = '&deviceTypeId=' + devTypeId;
      }
      $.ajax({
        url: "/threeColor/getInfo?size=1000&page=0&unit=" + searchContent,
        type: "GET",
        async: false,
        success: function (result) {
          $(".homepageSearchList").html("");
          var data = result.data.content;
          if (data.length == 1) {
            var searchAddress = data[0].address;
            var latitude = data[0].latitudes;
            var longitude = data[0].longitude;
            var devicecode = data[0].onlyValue;
            BaiDuMap.panTo(latitude, longitude, devicecode);
            setTimeout(function () {
              BaiDuMap.popMenu(devicecode);
            }, 700);

          }

        }
      });
    } else if (devTypeId == 'houseMaster') {
      // 搜索楼宇点位
      var searchContent = $(".homepageSearchBox .devAddress").val();
      searchContent = $.trim(searchContent);
      var devTypeIdStr = '';
      if (devTypeId != 'all') {
        devTypeIdStr = '&deviceTypeId=' + devTypeId;
      }
      $.ajax({
        url: "/building/getBuildings?size=1000&page=0&address=" + searchContent,
        type: "GET",
        async: false,
        success: function (result) {
          $(".homepageSearchList").html("");
          var data = result.data.content;
          for (var i = 0; i < data.length; i++) {
            var latitude = data[i].latitude;
            var longitude = data[i].longitude;
            var id = data[i].id;
            id = 'houseMaster' + id;
            var address = data[i].address;
            $(".homepageSearchList").append('<li devicecode="' + id + '" longitude="' + longitude + '" latitude="' + latitude + '">' + address + '</li>');
            hide2border();

          }
          if (data.length == 1) {
            var latitude = data[0].latitude;
            var longitude = data[0].longitude;
            var id = data[0].id;
            id = 'houseMaster' + id;
            var address = data[0].address;
            BaiDuMap.panTo(longitude, latitude);
            setTimeout(function () {
              BaiDuMap.popMenu(id);
            }, 700);

          }
        }
      });
    }
  }, 500);
  $('.homepageSearchBox i').click(function () {
    // 搜索设备
    homepageSearchListFn();

  });
  $('.index .deviceTypeToggleBtn1 li').on('click', function () {
    $(".homepageSearchBox .devAddress").val('');
  });
  $('.index .devAlltoggleBtn-content ul li').on('click', function () {
    $(".homepageSearchBox .devAddress").val('');
  });
  devListSum();
  // =================定位=================
  // 楼长制楼宇定位
  $('#buildingManagementModal').on('click', '.setPosition', function () {
    var index = $(this).parents('tr').index();
    var longitude = buildingContent[index].longitude;
    var latitude = buildingContent[index].latitude;
    var id = buildingContent[index].id;
    hideMapPoint();
    for (var i = 0; i < houseMasterMarker.length; i++) {
      houseMasterMarker[i].showOver();
    }
    map.closeInfoWindow();
    devTypeId = 'houseMaster';
    devTypeStatus = '';
    $('#houseMasterBtn').addClass('active').siblings().removeClass('active');
    $('.pointPositionBox-houseMaster').show().siblings('.pointPositionBox').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();

    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-houseMaster .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-houseMaster .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    $('.index .indexRightHeight').hide();
    $(".earlyWarningChartsShow").hide();
    $('.index .userBigBox').show();
    $('.combinedActionTaskStyle').hide();
    // combinedActionMarkerHide();
    $('.index .houseMasterChartsShow').show();
    // 隐藏
    // $('.index .homepageSearchBox .devAddress').attr('placeholder','请输入单位名称');
    devSumFunc();

    $(".buildingManagement-pop").removeClass("is-visible3");
    setTimeout(function () {
      BaiDuMap.panTo(longitude, latitude);
    }, 0);
    setTimeout(function () {
      BaiDuMap.popMenu('houseMaster' + id);
    }, 700);
  });
  // 地图三色预警定位
  $('#earlyWarningModal').on('click', '.earlyWarningPosition', function () {
    map.closeInfoWindow();
    hideMapPoint();
    for (var i = 0; i < earlyWarningMarker.length; i++) {
      earlyWarningMarker[i].showOver();
    }
    devTypeId = 'earlyWarning';
    devTypeStatus = '';
    $('#earlyWarningBtn').addClass('active').siblings().removeClass('active');
    // $(".pointPositionBox-smoke").hide();
    $('.pointPositionBox-earlyWarning').show().siblings('.pointPositionBox').hide();
    // $('.pointPositionBox-charge').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();
    // 显示三色预警饼状图
    $(".earlyWarningChartsShow").show();
    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-earlyWarning .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-earlyWarning .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    devSumFunc();
    devListSum();
    $('.combinedActionTaskStyle').hide();
    $('.authorizeDeviceStatistics').hide();
    $('.index .houseMasterChartsShow').hide();
    // combinedActionMarkerHide();

    $('.index .homepageSearchBox .devAddress').attr('placeholder', '请输入单位名称');

    var $this = $(this);
    var longitude = $this.attr('longitude');
    var latitude = $this.attr('latitude');
    var devCode = $this.attr('devCode');
    BaiDuMap.panTo(latitude, longitude);
    setTimeout(function () {
      BaiDuMap.popMenu(devCode);
    }, 700);
    if ($(event.target).is('.cd-popup-close') || $(event.target).is('.earlyWarning-pop')) {
      event.preventDefault();
      $('.earlyWarning-pop').removeClass('is-visible3');
    }

  });
  
  // 墙门点位定位
  $('#wallDoorModal').on('click', '.wallDoorPositionBtn', function () {
    var index = $(this).parents('tr').index();
    var longitude = editWallDoorArr[index].longitude;
    var latitude = editWallDoorArr[index].latitude;
    var id = editWallDoorArr[index].id;
    hideMapPoint();
    for (var i = 0; i < wallDoorMarker.length; i++) {
      wallDoorMarker[i].showOver();
    }
    map.closeInfoWindow();
    devTypeId = 'wallDoor';
    devTypeStatus = '';
    $('#wallDoorBtn').addClass('active').siblings().removeClass('active');
    $('.pointPositionBox-houseMaster').hide().siblings('.pointPositionBox').hide();
    $('.devAlltoggleBtn-title span').removeClass('active');
    $('.index .personnelStatisticsShow').hide();

    // 地图图标状态初始化为全部状态选中
    $(".pointPositionBox-houseMaster .pointPosition").find('.pointPositionImg').removeClass('active');
    $(".pointPositionBox-houseMaster .pointPosition").eq(0).find('.pointPositionImg').addClass('active');
    remove_ziyang_overlay();
    $('.index .indexRightHeight').hide();
    $(".earlyWarningChartsShow").hide();
    $('.index .userBigBox').show();
    $('.combinedActionTaskStyle').hide();
    // combinedActionMarkerHide();
    $('.index .houseMasterChartsShow').hide();
    // 隐藏
    // $('.index .homepageSearchBox .devAddress').attr('placeholder','请输入单位名称');
    devSumFunc();

    $("#wallDoorModal").removeClass("is-visible3");
    setTimeout(function () {
      BaiDuMap.panTo(longitude, latitude);
    }, 0);
    setTimeout(function () {
      BaiDuMap.popMenu('wallDoor' + id);
    }, 700);
  });
  // 关闭所有 删除 模态框 
  $("body").on("click", '.delTipCancelBtn', function (event) {
    event.preventDefault();
    $(".delTipCancelBox").removeClass("is-visible3");
  });

  
});
//-------------------------全局
function alarmSumInitFunc() {
  $.ajax({
    url: '/paging/notdispose/smoke/pageNumber',
    async: false,
    success: function (result) {
      var alarmSum = result.data.总条数;
      $('.indexLeft .alarmSum').text(alarmSum);
      $(".dataStatistics .dataHandleNum").val(alarmSum);

      if (alarmSum != 0) {
        $('.indexLeft').addClass('move');
        $('.indexLeft.untreatedAlarmNum').addClass('move1');
      } else {
        $('.indexLeft').removeClass('move');
        $('.indexLeft.untreatedAlarmNum').removeClass('move1');
      }
    }
  });

}
setInterval(function () {
  if (devTypeId == 'houseMaster') {
    $.ajax({
      url: '/building/getDataStatistics',
      success: function (res) {
        if (res.status == 200) {
          var data = res.data;
          $('.houseMasterChartsShow .buildingSum').text(data.楼宇数量);
          $('.houseMasterChartsShow .buildingPeopleSum').text(data.楼长人数);
          $('.houseMasterChartsShow .urgentSum').text(data.紧急);
          $('.houseMasterChartsShow .commonlySum').text(data.一般);
          $('.houseMasterChartsShow .reprieveSum').text(data.暂缓);
        }

      }
    });
  }

}, 10000);
//设备总数
function devSumFunc() {
  console.log(devTypeId)
  var devSum;
  $('.index .deviceStatistics').show();
  if (devTypeId == 'all') {
    $.ajax({
      url: '/device/count/bydevicetype',
      success: function (res) {
        devSum = res.data;
        
        $(".indexRightHeight .devSum").text(devSum);
        $(".deviceStatisticsRight").find(".titleText").text("设备统计");
        $(".deviceStatisticsRight").find(".deviceAvatar").css("background", "url(/public/images/deviceAvatar.png) no-repeat");
        // 设备总数显示
        $(".deviceStatisticsRight").find(".configuration-trigger").show();
        // 设备异常显示
        $(".deviceStatisticsRight").find(".unitException-trigger").show();
        // 三色预警隐藏
        $(".policeRatioBox").hide();
        $(".deviceStatisticsRight").find(".threeColorText").hide();
        // 微型消防站隐藏
        $(".deviceStatisticsRight").find(".miniFireStationText").hide();
        // 楼长制隐藏
        $(".deviceStatisticsRight").find(".buildingSystemText").hide();
        // 协同作战隐藏
        $(".deviceStatisticsRight").find(".cooCSumTextBox").hide();
        // 高层隐藏
        $(".deviceStatisticsRight").find(".highBuildText").hide();
        // 文历保隐藏
        $(".deviceStatisticsRight").find(".wenLiBaoText").hide();
      }
    });
    // else if (devTypeId == 'keepWatch' || devTypeId == 'earlyWarning') {
  } else if (devTypeId == 'keepWatch') {
    $('.index .deviceStatistics').hide();
  } else if (devTypeId == 'earlyWarning') {

    $.ajax({
      url: '/threeColor/getThreeColorWarningProportion?userid=' + localStorage.getItem('userId'),
      success: function (res) {

        var data1 = res.data[1];
        var data2 = res.data[2];
        var data3 = res.data[3];
        var devSum = data1 + data2 + data3;
        $(".deviceStatisticsRight .threeColorSum").text(devSum);
        $(".deviceStatisticsRight").find(".titleText").text("三色预警统计");
        $(".deviceStatisticsRight").find(".deviceAvatar").css("background", "url(/public/images/deviceAvatarThereColorLogo.png) no-repeat");
        $(".deviceStatisticsRight").find(".threeColorText").show();
        // 设备总数隐藏
        $(".deviceStatisticsRight").find(".configuration-trigger").hide();
        // 设备异常总数隐藏
        $(".deviceStatisticsRight").find(".unitException-trigger").hide();
        // 微型消防站隐藏
        $(".deviceStatisticsRight").find(".miniFireStationText").hide();
        // 楼长制隐藏
        $(".deviceStatisticsRight").find(".buildingSystemText").hide();
        // 协同作战隐藏
        $(".deviceStatisticsRight").find(".cooCSumText").hide();
        // 高层隐藏
        $(".deviceStatisticsRight").find(".highBuildText").hide();
        // 文历保隐藏
        $(".deviceStatisticsRight").find(".wenLiBaoText").hide();


      }
    });

  } else if (devTypeId == 'houseMaster') { // 楼长制
    $('.index .deviceStatistics').hide();
    $(".indexRight .buildingSystemSum").text(28);
    $(".deviceStatisticsRight").find(".titleText").text("楼长制统计");
    $(".deviceStatisticsRight").find(".deviceAvatar").css("background", "url(/public/images/deviceAvatarLou.png) no-repeat");
    // 三色预警隐藏
    $(".deviceStatisticsRight").find(".threeColorText").hide();
    // 设备总数隐藏
    $(".deviceStatisticsRight").find(".configuration-trigger").hide();
    // 设备异常总数隐藏
    $(".deviceStatisticsRight").find(".unitException-trigger").hide();
    // 微型消防站隐藏
    $(".deviceStatisticsRight").find(".miniFireStationText").hide();
    // 楼长制显示
    $(".deviceStatisticsRight").find(".buildingSystemText").show();
    // 协同作战隐藏
    $(".deviceStatisticsRight").find(".cooCSumTextBox").hide();
    // 高层隐藏
    $(".deviceStatisticsRight").find(".highBuildText").hide();
    // 文历保隐藏
    $(".deviceStatisticsRight").find(".wenLiBaoText").hide();
    // 楼长制本月数据统计图表数据
    $.ajax({
      url: '/building/getDataStatistics',
      success: function (res) {
        if (res.status == 200) {
          var data = res.data;
          $('.houseMasterChartsShow .buildingSum').text(data.楼宇数量);
          $('.houseMasterChartsShow .buildingPeopleSum').text(data.楼长人数);
          $('.houseMasterChartsShow .urgentSum').text(data.紧急);
          $('.houseMasterChartsShow .commonlySum').text(data.一般);
          $('.houseMasterChartsShow .reprieveSum').text(data.暂缓);
        }

      }
    });
  } else if (devTypeId == 'combinedAction') { // 协同作战
    // $.ajax({
    // url: '/threeColor/getRectifyInfo?size=1&page=0',
    // success: function (res) {
    // console.log(res);
    // devSum = res.data.totalElements;
    // $(".deviceStatisticsRight .threeColorSum").text(devSum);
    $(".deviceStatisticsRight").find(".titleText").text("协同作战统计");
    $(".deviceStatisticsRight").find(".deviceAvatar").css("background", "url(/public/images/deviceAvatarCoo.png) no-repeat");
    $(".deviceStatisticsRight").find(".threeColorText").hide();
    // 设备总数隐藏
    $(".deviceStatisticsRight").find(".configuration-trigger").hide();
    // 设备异常总数隐藏
    $(".deviceStatisticsRight").find(".unitException-trigger").hide();
    // 微型消防站隐藏
    $(".deviceStatisticsRight").find(".miniFireStationText").hide();
    // 楼长制隐藏
    $(".deviceStatisticsRight").find(".buildingSystemText").hide();
    // 协同作战显示
    $(".deviceStatisticsRight").find(".cooCSumTextBox").show();
    // 高层隐藏
    $(".deviceStatisticsRight").find(".highBuildText").hide();
    // 文历保隐藏
    $(".deviceStatisticsRight").find(".wenLiBaoText").hide();
    // }
    // });         
  } else if (devTypeId == 'building') { // 高层
    // $.ajax({
    //   url: '/threeColor/getRectifyInfo?size=1&page=0',
    //   success: function (res) {
    // console.log(res);
    // devSum = res.data.totalElements;
    // $(".deviceStatisticsRight .threeColorSum").text(devSum);

    $('.indexRight .highBuildSum').text(hightBuildingNumOnly);
    $(".deviceStatisticsRight").find(".titleText").text("高层统计");
    $(".deviceStatisticsRight").find(".deviceAvatar").css("background", "url(/public/images/deviceAvatarHigh.png) no-repeat");
    $(".deviceStatisticsRight").find(".threeColorText").hide();
    // 设备总数隐藏
    $(".deviceStatisticsRight").find(".configuration-trigger").hide();
    // 设备异常总数隐藏
    $(".deviceStatisticsRight").find(".unitException-trigger").hide();
    // 微型消防站隐藏
    $(".deviceStatisticsRight").find(".miniFireStationText").hide();
    // 楼长制隐藏
    $(".deviceStatisticsRight").find(".buildingSystemText").hide();
    // 协同作战显示
    $(".deviceStatisticsRight").find(".cooCSumTextBox").hide();
    // 高层隐藏
    $(".deviceStatisticsRight").find(".highBuildText").show();
    // 文历保隐藏
    $(".deviceStatisticsRight").find(".wenLiBaoText").hide();
    //   }
    // });         
  } else if (devTypeId == 'wenbao') { // 文历保
    // $.ajax({
    //   url: '/threeColor/getRectifyInfo?size=1&page=0',
    //   success: function (res) {
    // console.log(res);
    // devSum = res.data.totalElements;
    // $(".deviceStatisticsRight .threeColorSum").text(devSum);
    $(".deviceStatisticsRight").find(".titleText").text("文历保统计");
    $(".deviceStatisticsRight").find(".deviceAvatar").css("background", "url(/public/images/deviceAvatarWen.png) no-repeat");
    $(".deviceStatisticsRight").find(".threeColorText").hide();
    // 设备总数隐藏
    $(".deviceStatisticsRight").find(".configuration-trigger").hide();
    // 设备异常总数隐藏
    $(".deviceStatisticsRight").find(".unitException-trigger").hide();
    // 微型消防站隐藏
    $(".deviceStatisticsRight").find(".miniFireStationText").hide();
    // 楼长制隐藏
    $(".deviceStatisticsRight").find(".buildingSystemText").hide();
    // 协同作战显示
    $(".deviceStatisticsRight").find(".cooCSumTextBox").hide();
    // 高层隐藏
    $(".deviceStatisticsRight").find(".highBuildText").hide();
    // 文历保隐藏
    $(".deviceStatisticsRight").find(".wenLiBaoText").show();
    //   }
    // });         
  } else if (devTypeId == 'keyPerson') { // 重点人员
    $(".indexRightHeight .devSum").text(devSum);
    $(".deviceStatisticsRight").find(".titleText").text("设备统计");
    $(".deviceStatisticsRight").find(".deviceAvatar").css("background", "url(/public/images/deviceAvatar.png) no-repeat");
    // 设备总数显示
    $(".deviceStatisticsRight").find(".configuration-trigger").show();
    // 设备异常显示
    $(".deviceStatisticsRight").find(".unitException-trigger").show();
    // 三色预警隐藏
    $(".policeRatioBox").hide();
    $(".deviceStatisticsRight").find(".threeColorText").hide();
    // 微型消防站隐藏
    $(".deviceStatisticsRight").find(".miniFireStationText").hide();
    // 楼长制隐藏
    $(".deviceStatisticsRight").find(".buildingSystemText").hide();
    // 协同作战隐藏
    $(".deviceStatisticsRight").find(".cooCSumTextBox").hide();
    // 高层隐藏
    $(".deviceStatisticsRight").find(".highBuildText").hide();
    // 文历保隐藏
    $(".deviceStatisticsRight").find(".wenLiBaoText").hide();
    $('.indexRight .configuration-trigger .devSum').text(keyPersonNum);
    $('.indexRight .unitExceptionText .abnormalSum').text(0);
  } else if (devTypeId == 'wallDoor') { // 墙门
    $(".deviceStatisticsRight").hide();
  } else {
    $.ajax({
      url: '/device/count/bydevicetype?deviceTypeId=' + devTypeId,
      success: function (res) {
        devSum = res.data;
        $(".indexRightHeight .devSum").text(devSum);
        $(".deviceStatisticsRight").find(".titleText").text("设备统计");
        $(".deviceStatisticsRight").find(".deviceAvatar").css("background", "url(/public/images/deviceAvatar.png) no-repeat");
        // 设备总数显示
        $(".deviceStatisticsRight").find(".configuration-trigger").show();
        // 设备异常显示
        $(".deviceStatisticsRight").find(".unitException-trigger").show();
        // 三色预警隐藏
        $(".policeRatioBox").hide();
        $(".deviceStatisticsRight").find(".threeColorText").hide();
        // 微型消防站隐藏
        $(".deviceStatisticsRight").find(".miniFireStationText").hide();
        // 楼长制隐藏
        $(".deviceStatisticsRight").find(".buildingSystemText").hide();
        // 协同作战隐藏
        $(".deviceStatisticsRight").find(".cooCSumTextBox").hide();
        // 高层隐藏
        $(".deviceStatisticsRight").find(".highBuildText").hide();
        // 文历保隐藏
        $(".deviceStatisticsRight").find(".wenLiBaoText").hide();
      }
    });
  }

  $.ajax({
    url: '/device/count/bydevicetype?deviceTypeId=1',
    success: function (res) {
      devSum = res.data;
      $(".dataStatistics .dataSmokeSum").val(devSum);
    }
  });
}
//本月报警总数
function thisMonthFunc() {

  var beginTime = moment().add('days', 0).format("YYYY-MM-DD") + ' 00:00:00';
  var endTime = moment().add('days', 0).format("YYYY-MM-DD") + ' 23:59:59';
  $.ajax({
    url: '/alarm/data/history/simple/list?beginTime=' + beginTime + '&endTime=' + endTime + '&alarmTypeCode=001&deviceTypeId=001',
    success: function (res) {
      var devSum = res.data.length;
      $(".indexCenter .alarmData .alarmDataNum span").text(devSum);
    }
  });
  var beginTimeSeven = moment().add('days', -6).format("YYYY-MM-DD") + ' 00:00:00';
  var endTimeSeven = moment().add('days', 0).format("YYYY-MM-DD") + ' 23:59:59';
  $.ajax({
    url: '/alarm/data/history/simple/list?beginTime=' + beginTimeSeven + '&endTime=' + endTimeSeven + '&alarmTypeCode=001&deviceTypeId=001',
    success: function (res) {
      var devSum = res.data.length;
      $(".dataStatistics .dataSumAlarm").val(devSum);
    }
  });
}


function devListSum() {
  var alarmSum = 0;
  var faultSum = 0;
  var lowSum = 0;
  var normalSum = 0;
  var devSum = 0;
  var lowfaultSum;
  var chargeSum10 = 0;
  var chargeSum12 = 0;
  var chargeSum13 = 0;
  var chargeSum14 = 0;
  var chargeSum16 = 0;
  var chargeSum17 = 0;
  var chargeSum = 0;
  var chargeAbnormal = 0;
  var devAbnormal = 0;
  
  if (devTypeId == 1) {
    //烟感
    // $.ajax({
    //   url: '/deviceStatus/data/list/bydevicetype?deviceTypeId=1',
    //   success: function (res) {
    //     var data = res.data;
    //     for (var i = 0; i < res.data.length; i++) {
    //       status = data[i].status;
    //       if (status == 1) {
    //         alarmSum += 1;
    //       } else if (status == 3) {
    //         faultSum += 1;
    //       } else if (status == 4) {
    //         lowSum += 1;
    //       } else if (status == 7) {
    //         normalSum += 1;
    //       }
    //       devSum += 1;
    //     }
    //     lowfaultSum = lowSum + faultSum;

    //     $('#alarmPointPosition .tip').text(alarmSum);
    //     $('#lowPointPosition .tip').text(lowSum);
    //     $('#faultPointPosition .tip').text(faultSum);
    //     $('#normalPointPosition .tip').text(normalSum);
    //     $(".indexRightHeight .abnormalSum").text(lowfaultSum);
    //   }
    // });
    $.ajax({
      url: '/device/count/bydevicetype?status=all&deviceTypeId=1',
      success: function (res) {
        var data = res.data;
        $(".indexRightHeight .abnormalSum").text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=1&deviceTypeId=1',
      success: function (res) {
        var data = res.data;
        $('#alarmPointPosition .tip').text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=3&deviceTypeId=1',
      success: function (res) {
        var data = res.data;
        $('#faultPointPosition .tip').text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=4&deviceTypeId=1',
      success: function (res) {
        var data = res.data;
        $('#lowPointPosition .tip').text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=7&deviceTypeId=1',
      success: function (res) {
        var data = res.data;
        $('#normalPointPosition .tip').text(data);
      }
    });
  } else if (devTypeId == 2) {
    //充电桩
    // $.ajax({
    //   url: '/deviceStatus/data/list/bydevicetype?deviceTypeId=2',
    //   success: function (res) {
    //     var data = res.data;
    //     for (var i = 0; i < res.data.length; i++) {
    //       status = data[i].status;
    //       if (status == 10) {
    //         chargeSum10 += 1;
    //       } else if (status == 12) {
    //         chargeSum12 += 1;
    //       } else if (status == 13) {
    //         chargeSum13 += 1;
    //       } else if (status == 14) {
    //         chargeSum14 += 1;
    //       } else if (status == 16) {
    //         chargeSum16 += 1;
    //       } else if (status == 17) {
    //         chargeSum17 += 1;
    //       }
    //       chargeSum += 1;
    //     }
    //     chargeAbnormal = chargeSum12 + chargeSum13+chargeSum14+chargeSum16;
    //     $('#normalPointPosition-charge .tip').text(chargeSum10);
    //     $('#abnormalPointPosition-charge .tip').text(chargeAbnormal);
    //     $('#faultPointPosition-charge .tip').text(chargeSum17);

    //     $(".indexRightHeight .abnormalSum").text(chargeAbnormal+chargeSum17);
    //   }
    // });
    var abnormalPointSum = 0;
    var abnormalPointSum1 = 0;
    var abnormalPointSum2 = 0;
    $.ajax({
      url: '/device/count/bydevicetype?status=all&deviceTypeId=2',
      async: false,
      success: function (res) {
        var data = res.data;
        abnormalPointSum1 = data;
        $(".indexRightHeight .abnormalSum").text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=10&deviceTypeId=2',
      success: function (res) {
        var data = res.data;
        $('#normalPointPosition-charge .tip').text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=17&deviceTypeId=2',
      async: false,
      success: function (res) {
        var data = res.data;
        abnormalPointSum2 = data;
        $('#faultPointPosition-charge .tip').text(data);
      }
    });

    abnormalPointSum = abnormalPointSum1 - abnormalPointSum2;
    
    $('#abnormalPointPosition-charge .tip').text(abnormalPointSum);
  } else if (devTypeId == 3) {
    $(".indexRightHeight .abnormalSum").text(0);
    //GPS人员
    // $.ajax({
    //   url: '/device/count/bydevicetype?status=30&deviceTypeId=3',
    //   success: function (res) {
    //     var data = res.data;
    //     $("#normalPointPosition-GPS .tip").text(data);
    //   }
    // });
    // $.ajax({
    //   url: '/device/count/bydevicetype?status=30&deviceTypeId=3',
    //   success: function (res) {
    //     var data = res.data;
    //     $("#abnormalPointPosition-GPS .tip").text(data);
    //   }
    // });
    // $.ajax({
    //   url: '/device/count/bydevicetype?status=30&deviceTypeId=3',
    //   success: function (res) {
    //     var data = res.data;
    //     $("#faultPointPosition-GPS .tip").text(data);
    //   }
    // });
  } else if (devTypeId == 4) {
    //消火栓
    $.ajax({
      url: '/device/count/bydevicetype?status=all&deviceTypeId=4',
      success: function (res) {
        var data = res.data;
        $(".indexRightHeight .tip").text(data);
      }
    });
    // 正常
    $.ajax({
      url: '/device/count/bydevicetype?status=30&deviceTypeId=4',
      success: function (res) {
        var data = res.data;
        $("#normalPointPosition-fireplug .tip").text(data);
      }
    });
    // 低压或高压报警
    var fireplugAlarmSum = 0;
    var fireplugAlarmSum1 = 0;
    var fireplugAlarmSum2 = 0;
    $.ajax({
      url: '/device/count/bydevicetype?status=31&deviceTypeId=4',
      success: function (res) {
        var fireplugAlarmSum1 = res.data;
        // $("#lowPointPosition-fireplug .tip").text(data);
      }
    });
    // 高压
    $.ajax({
      url: '/device/count/bydevicetype?status=32&deviceTypeId=4',
      success: function (res) {
        var fireplugAlarmSum2 = res.data;
        // $("#alarmPointPosition-fireplug .tip").text(data);
      }
    });
    fireplugAlarmSum = fireplugAlarmSum1 + fireplugAlarmSum2;
    $("#alarmPointPosition-fireplug .tip").text(fireplugAlarmSum);
    // 故障
    $.ajax({
      url: '/device/count/bydevicetype?status=33&deviceTypeId=4',
      success: function (res) {
        var data = res.data;
        $("#faultPointPosition-fireplug .tip").text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=all&deviceTypeId=4',
      success: function (res) {
        var data = res.data;
        $(".indexRightHeight .abnormalSum").text(data);
      }
    });
  } else if (devTypeId == 5) {
    // 智能用电
    $(".indexRightHeight .abnormalSum").text(0);
    $.ajax({
      url: '/device/count/bydevicetype?status=40&deviceTypeId=5',
      success: function (res) {
        var data = res.data;
        $("#normalPointPosition-electricity .tip").text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=41&deviceTypeId=5',
      success: function (res) {
        var data = res.data;
        $("#lowPointPosition-electricity .tip").text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=42&deviceTypeId=5',
      success: function (res) {
        var data = res.data;
        $("#alarmPointPosition-electricity .tip").text(data);
      }
    });

    $.ajax({
      url: '/device/count/bydevicetype?status=43&deviceTypeId=5',
      success: function (res) {
        var data = res.data;
        $("#faultPointPosition-electricity .tip").text(data);
      }
    });


  } else if (devTypeId == 6) {
    //水位检测
    $.ajax({
      url: '/device/count/bydevicetype?status=50&deviceTypeId=6',
      success: function (res) {
        var data = res.data;
        $("#normalPointPosition-water .tip").text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=51&deviceTypeId=6',
      success: function (res) {
        var data = res.data;
        $("#abnormalPointPosition-water .tip").text(data);
      }
    });
    $.ajax({
      url: '/device/count/bydevicetype?status=52&deviceTypeId=6',
      success: function (res) {
        var data = res.data;
        $("#faultPointPosition-water .tip").text(data);
      }
    });

    $.ajax({
      url: '/device/count/bydevicetype?status=all&deviceTypeId=6',
      success: function (res) {
        var data = res.data;
        
        $(".indexRightHeight .abnormalSum").text(data);
      }
    });
  } else if (devTypeId == 7) {
    //视频
    $.ajax({
      url: '/device/count/bydevicetype?status=60&deviceTypeId=7',
      success: function (res) {
        var data = res.data;
        $("#normalPointPosition-video .tip").text(data);
      }
    });

    $.ajax({
      url: '/device/count/bydevicetype?status=all&deviceTypeId=7',
      success: function (res) {
        var data = res.data;
        
        $(".indexRightHeight .abnormalSum").text(data);
      }
    });
  } else if (devTypeId == 'earlyWarning') {
    //三色预警  TODO
    $.ajax({
      url: '/threeColor/getThreeColorWarningProportion?userid=' + localStorage.getItem('userId'),
      success: function (res) {
        
        var data1 = res.data[1];
        var data2 = res.data[2];
        var data3 = res.data[3];
        $("#commonlyPointPosition-earlyWarning .tip").text(data1);
        $("#middlePointPosition-earlyWarning .tip").text(data2);
        $("#heightPointPosition-earlyWarning .tip").text(data3);
      }
    });

  } else if (devTypeId == 'all') {
    // 设备异常总数
    devAbnormalSumFUnc();
  }

}

// 设备异常总数
function devAbnormalSumFUnc() {
  $.ajax({
    url: '/device/count/bydevicetype?status=all',
    success: function (res) {
      var data = res.data;
      
      $(".indexRightHeight .abnormalSum").text(data);
    }
  });
}
//微型消防站数量
function fireStationNum() {
  $.ajax({
    url: '/organization/organizationfire/all?type=fireStation',
    success: function (res) {
      
      $('.indexCenter .miniFireBox span').text(res.data.length);
      $('.miniFireStationSum').text(res.data.length);
      $('.indexCenter .onlineFireBox span').text(res.data.length);
    }
  });
}
//操作提示框
function tipModalFunc(str) {
  $('#tipModal .modal-title').text(str);
  $('.tip-pop').addClass('is-visible3');
}
// 是否删除 确认框
function delTipModalFunc(str) {
  $('#delTipModal .modal-title').text(str);
  $('.delTipModal').addClass('is-visible3');
}
//创建二维码---label--  createQRCode('earlyWarningQrcode'+onlyvalue, 180, onlyvalue, "img/logo.png", qrCodeName);
function createQRCodeLabel(id, size, url, src, label) {
  $(id).empty();
  jQuery(id).qrcode({
    render: 'canvas',
    text: url,
    // width : width,              //二维码的宽度  
    // height : height,            //二维码的高度  
    // imgWidth : width/4,         //图片宽
    // imgHeight : height/4,       //图片高
    src: src, //图片中央的二维码
    ecLevel: 'H', //误差校正水平选择最高级
    mode: 1, //label模式选择2
    label: label,
    fontname: 'Arial',
    fontcolor: '#458fd2',
    background: "#ffffff", //二维码的后景色  
    foreground: "#000", //二维码的前景色  
    typeNumber: -1,
    mSize: 0.019,
    size: size,
    mPosX: 0.5,
    mPosY: 0.99, //logo 文字的位置
    quiet: 3 // 安静区域 即周边空白区域
  });
}